package math.vectorSpace.R3.object;

import java.awt.Graphics2D;

import math.vectorSpace.R3.Point3D;
import math.vectorSpace.R3.visualization.Render3D;
import math.vectorSpace.R3.visualization.VisualizationProperties;

public class Sphere3D extends MovableObject {

    private double radius;

    public Sphere3D(Point3D center, double radius) {
        this.center = center;
        this.radius = radius;
    }

    public double getRadius() {
        return radius;
    }

    public void setRadius(double r) {
        radius = r;
    }

    @Override
    public void scale(double scaleFactor) {
        radius *= scaleFactor;
    }

    @Override
    public void move() {
        if ((center.getX() + radius > end.getX())
                || (center.getX() - radius < start.getX())) {
            speedX = -speedX;
        }
        if ((center.getY() + radius > end.getY())
                || (center.getY() - radius < start.getY())) {
            speedY = -speedY;
        }
        if ((center.getZ() + radius > end.getZ())
                || (center.getZ() - radius < start.getZ())) {
            speedZ = -speedZ;
        }
        center = center.add(speedX, speedY, speedZ);
    }

    /*
     * All of the rotate methods are empty since rotating a sphere around 
     * any axis is meaningless
     */
    @Override
    public void rotateX(double angle) {
    }

    @Override
    public void rotateY(double angle) {
    }

    @Override
    public void rotateZ(double angle) {
    }

    @Override
    public void draw(Render3D r, Graphics2D g,
            VisualizationProperties properties) {
        g.setColor(properties.getFillColor());
        center.draw(r, g, properties, radius);
    }
}
